{% extends 'foot.html' %}

{% block script %}
<script>
	$(function(){
	var error_username;

	$('.name_input').blur(function() {
		check_user_name();
	});

	function check_user_name(){
        $.get('/user/login_judge/?user_name='+$('.name_input').val(), function (data) {
            if(data.count==0)
            {
                $('.user_error').text('用户名不存在，请前往注册').show();
                error_username = true;
            }
            else
            {
            	$('.user_error').hide();
            	error_username = false;
            }
        });
	}

	if ({{error_pwd}}==1){
		$('.pwd_error').text('密码错误').show()
	}

	$('form').submit(function() {
		check_user_name();

		if (error_username)
		{
			return false;
		}

	});

	})
</script>
{% endblock script %}

{% block main %}
	<div class="login_top clearfix">
		<a href="index.html" class="login_logo"><img src="/static/images/logo02.png"></a>
	</div>

	<div class="login_form_bg">
		<div class="login_form_wrap clearfix">
			<div class="login_banner fl"></div>
			<div class="slogan fl">日夜兼程 · 急速送达</div>
			<div class="login_form fr">
				<div class="login_title clearfix">
					<h1>用户登录</h1>
					<a href="/user/register/">立即注册</a>
				</div>
				<div class="form_input">
					<form action="/user/login_handler/" method="post">
						{% csrf_token %}
						<input type="text" name="username" class="name_input" value="{{ username }}" placeholder="请输入用户名">
						<div class="user_error">输入错误</div>
						<input type="password" name="pwd" class="pass_input" value="{{ userpwd }}" placeholder="请输入密码">
						<div class="pwd_error">输入错误</div>
						<div class="more_input clearfix">
							<input type="checkbox" name="remember" value="1" checked="checked">
							<label>记住用户名</label>
							<a href="/user/forget/">忘记密码</a>
						</div>
						<input type="submit" value="登录" class="input_submit">
					</form>
				</div>
			</div>
		</div>
	</div>
{% endblock main %}
